<template>
    <div class="data-content">
        <el-table :data="itemList" border style="width: 100%">
            <el-table-column fixed label="序号" width="50">
                <template slot-scope="scope">
                    <span>{{ (page - 1) * pageSize + scope.$index + 1 }}</span>
                </template>
            </el-table-column>
            <el-table-column prop="ratingCompanyName" label="评级公司" width="400">
            </el-table-column>
            <el-table-column prop="alias" label="评级公司简称">
            </el-table-column>
            <el-table-column prop="ratingOutlook" label="评级展望">
            </el-table-column>
            <el-table-column prop="subjectLevel" label="主体等级">
            </el-table-column>
            <el-table-column prop="bondCreditLevel" label="债券信用等级">
            </el-table-column>
            <el-table-column prop="ratingDate" label="评级时间">
            </el-table-column>
        </el-table>
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next"
            style="text-align:right; margin-top:1em;"
            :total="total">
        </el-pagination>
        <el-link v-if="isLink" type="info" :underline="false">*此数据来源于天眼查官方网站</el-link>
    </div>
</template>

<script>
export default {
    props: {
        companyName: {
            type: String,
            default: "",
        },
        projectId: {
            type: String,
            default: "",
        },
        nodeId: { //导航标签id
            type: String,
            default: ''
        }
    },
    data: () => ({
        size: 1,
        page: 1,
        pageSize: 10,
        itemList: [],
        total: null
    }),
    computed: {
        isLink() {
            return this.itemList.length > 0 ? true : false 
        }
    },
    methods: {
        handleSizeChange: function (size) {
            this.size = size;
            this.getList()
        },
        handleCurrentChange: function(page){
            this.page = page;
            this.getList()
        },
        //获取企业基本信息
        getList() {
            var that = this;
            this.$ajax({
                type: "get",
                url: `${that.$store.state.api.searchUrl}/searchtianyan/getCreditRating`,
                data: {
                    corpName: that.companyName,
                    projectId: that.projectId,
                    pageNum: this.page,
                    pageSize: this.pageSize,
                },
                callback: function (data, res) {
                    if(data.result) {
                        that.itemList = data.result.items;
                        that.total = data.result.total;
                        this.$emit("pushValidNames",this.nodeId)
                    }
                    
                },
            });
        },
    },
    mounted() {
        this.getList();
    },
};
</script>

<style scoped lang="scss">
.data-content {
    // border-bottom: 1px solid #efefef;
    padding: 10px 0px;
}
</style>
